package com.example.system.controller.question;

import cn.hutool.core.collection.CollectionUtil;
import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.R;
import com.example.common.core.domain.TableDataInfo;
import com.example.system.domain.question.Question;
import com.example.system.domain.question.dto.QuestionAddDTO;
import com.example.system.domain.question.dto.QuestionEditDTO;
import com.example.system.domain.question.dto.QuestionQueryDTO;
import com.example.system.domain.question.vo.QuestionDetailVO;
import com.example.system.domain.question.vo.QuestionVO;
import com.example.system.service.question.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Autowired
    private QuestionService questionService;
    @GetMapping("/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return getDataTable(questionService.list(questionQueryDTO));
    }

    @PostMapping("/add")
    public R<Void> add(@RequestBody QuestionAddDTO questionAddDTO) {
        return toR(questionService.add(questionAddDTO));
    }


    @DeleteMapping("/delete")
    public R<Void> delete(Long id) {
        return toR(questionService.delete(id));
    }

    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long id) {
        return questionService.detail(id);
    }

    @PutMapping("/update")
    public R<Void> update(@RequestBody QuestionEditDTO questionEditDTO) {
        return toR(questionService.update(questionEditDTO));
    }
}

